class PayableBill < ActiveRecord::Base
  acts_as_paranoid
  
  validates_presence_of     :bill, :user, :amount
  validates_numericality_of :amount
  
  belongs_to :bill
  belongs_to :account
  belongs_to :user
  
  def name
    bill.name
  end
  
  def due
    bill.due
  end
  
  def details
    '$' + self.amount + ' due on ' + self.due.to_s(:short)
  end
  
  def unpaid?
    self.paid_at.nil?
  end

  def paid?
    !self.paid_at.nil?
  end
  
  def due_status
    if self.bill.due > 7.days.from_now.to_date
      'ok'
    elsif self.bill.due > 3.days.from_now.to_date
      'warning'
    else
      'exclamation'
    end
  end
end
